Imports System.Collections

Partial Class pages_locations_usercontrols_UCLocation : Inherits UserControl

#Region "Members"
    Private m_location As CLocation
    Private m_sortedList As IList
#End Region

#Region "Interface"
    Public Sub Display(ByVal [location] As CLocation, sortedList as IList)
        If Parent.Controls.Count Mod 2 = 0 Then row.Attributes.Add("class", "alt_row")

        m_location = [location]
        m_sortedList = sortedList

        With m_location
            litNumber.Text = CStr(sortedList.IndexOf(m_location) + 1)
            lnkLocationName.Text =  CStr(IIF(.LocationName.Length = 0, "...", .LocationName))
            lnkLocationName.NavigateUrl = CSitemap.LocationEdit(.LocationId)

            lnkProducts.Text = CUtilities.CountSummary(.Products, "product", "none")
            lnkProducts.NavigateUrl = CSitemap.ProductsForLocation(.LocationId)
        End With
    End Sub
#End Region

#Region "Event Handlers"
    Private Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnDelete.Click
        m_location.Delete()
        Refresh()
    End Sub
#End Region

#Region "Private"
    Private Sub Refresh()
        'CCache.ClearCache()

        'If False Then 'Request.RawUrl.ToLower.Contains("myparent.aspx") Then
        '    'Special case: Parent entity owns the list
        '    Response.Redirect(CSitemap.MyParentEdit(m_location.LocationParentId, MyParent.ETab.locations, m_pageIndex)
        'Else
        '    'Normal case: Search page owns the list
            Response.Redirect(Request.RawUrl) 'includes paging info
        'End If 
    End Sub
#End Region

End Class
